/**
 * 
 */
package com.alphasystem.ecommerce.test;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import javax.ejb.embeddable.EJBContainer;
import javax.naming.Context;

import org.apache.log4j.xml.DOMConfigurator;
import org.testng.annotations.Factory;

import com.alphasystem.ecommerce.test.locale.LocaleTest;
import com.alphasystem.ecommerce.test.sequence.SequenceTest;

/**
 * @author sali
 * 
 */
public class EcommerceTestFactory {

	static {
		URL url = Thread.currentThread().getContextClassLoader()
				.getResource("log4j.xml");
		DOMConfigurator.configure(url);
	}

	@Factory
	public Object[] createTests() {
		List<Object> tests = new ArrayList<Object>();

		final Properties p = new Properties();
		p.put("testDatabase", "new://Resource?type=DataSource");
		p.put("testDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
		p.put("testDatabase.JdbcUrl", "jdbc:hsqldb:mem:testdb");

		final Context context = EJBContainer.createEJBContainer(p).getContext();

		tests.add(new SequenceTest(context));
		tests.add(new LocaleTest(context));

		System.out.println(tests);

		return tests.toArray();
	}
}
